package com.jd.sentinelspringboot.apollo;

import com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SentinelApolloConfig {

    @Value("${spring.application.name}")
    private String applicationName;


    @Bean
    @ConditionalOnMissingBean
    public SentinelResourceAspect resourceAspect(){
        return new SentinelResourceAspect();
    }


    @Bean
    @ConditionalOnMissingBean
    public ApolloDataSorceListener apolloDataSorceListener(){
        return new ApolloDataSorceListener(applicationName);
    }


}
